package com.meiwenhui.freemarkstruts.action;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.UUID;

import org.apache.struts2.ServletActionContext;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class FreemarkstrutsAction extends ActionSupport {

	@Override
	public String execute() throws Exception {
		System.out.println("-----------");
		List<Entity> colls = new ArrayList<Entity>();
		for (int i = 0; i < 10; i++) {
			Entity entity = new Entity();
			entity.setId(new Random().nextInt(100));
			entity.setName(UUID.randomUUID().toString().substring(0, 6));
			entity.setPassword(UUID.randomUUID().toString().replace("-", ""));
			colls.add(entity);
		}
		ServletActionContext.getRequest().setAttribute("colls", "colls");
		return SUCCESS;
	}

	class Entity {

		private long id;
		private String name;
		private String password;

		public long getId() {
			return id;
		}

		public void setId(long id) {
			this.id = id;
		}

		public String getName() {
			return name;
		}

		public void setName(String name) {
			this.name = name;
		}

		public String getPassword() {
			return password;
		}

		public void setPassword(String password) {
			this.password = password;
		}

	}

}
